import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    tasklist:[],
  },
  getters: {
    unFinish(state){
      var arr = state.tasklist.filter((item)=>{
        return item.status ==false
      })
      return arr.length
    }
  },
  mutations: {
    addTask(state,payload){
      var obj = {id:state.tasklist.length+1,name:payload,status:false}
      state.tasklist.push(obj)
    },
    change(state,payload){
      let f = state.tasklist.find((item)=>{
        return item.id == payload.id
      })
      if (f) {
        f.status=!f.status
      }
    }
  },
  actions: {
  },
  modules: {
  }
})
